package com.neo.web;

import org.springframework.core.io.Resource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.File;

@Component
public class UploadResourceHandler {

    @Value("${upload.path}")
    private String uploadPath;

    public Resource getResource(String fileName) {
        // 这里假设fileName是要查找的文件名，uploadPath是从配置中读取的路径
        // 注意：如果uploadPath指向的是类路径内的资源，应使用ClassPathResource
        // 如果是指向文件系统的路径，则使用FileSystemResource
        Resource fileResource = new FileSystemResource(uploadPath + File.separator + fileName);

        return fileResource;
    }
}
